<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module MakeMakefile - mkmf: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="MakeMakefile.html">MakeMakefile</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-5B-5D">::[]</a>
    <li ><a href="#method-c-5B-5D-3D">::[]=</a>
    <li ><a href="#method-i-append_cflags">#append_cflags</a>
    <li ><a href="#method-i-cc_command">#cc_command</a>
    <li ><a href="#method-i-check_signedness">#check_signedness</a>
    <li ><a href="#method-i-check_sizeof">#check_sizeof</a>
    <li ><a href="#method-i-conftest_source">#conftest_source</a>
    <li ><a href="#method-i-convertible_int">#convertible_int</a>
    <li ><a href="#method-i-create_header">#create_header</a>
    <li ><a href="#method-i-create_makefile">#create_makefile</a>
    <li ><a href="#method-i-depend_rules">#depend_rules</a>
    <li ><a href="#method-i-dir_config">#dir_config</a>
    <li ><a href="#method-i-dummy_makefile">#dummy_makefile</a>
    <li ><a href="#method-i-enable_config">#enable_config</a>
    <li ><a href="#method-i-find_executable">#find_executable</a>
    <li ><a href="#method-i-find_header">#find_header</a>
    <li ><a href="#method-i-find_library">#find_library</a>
    <li ><a href="#method-i-find_type">#find_type</a>
    <li ><a href="#method-i-have_const">#have_const</a>
    <li ><a href="#method-i-have_devel-3F">#have_devel?</a>
    <li ><a href="#method-i-have_framework">#have_framework</a>
    <li ><a href="#method-i-have_func">#have_func</a>
    <li ><a href="#method-i-have_header">#have_header</a>
    <li ><a href="#method-i-have_library">#have_library</a>
    <li ><a href="#method-i-have_macro">#have_macro</a>
    <li ><a href="#method-i-have_struct_member">#have_struct_member</a>
    <li ><a href="#method-i-have_type">#have_type</a>
    <li ><a href="#method-i-have_var">#have_var</a>
    <li ><a href="#method-i-link_command">#link_command</a>
    <li ><a href="#method-i-pkg_config">#pkg_config</a>
    <li ><a href="#method-i-try_const">#try_const</a>
    <li ><a href="#method-i-try_type">#try_type</a>
    <li ><a href="#method-i-with_config">#with_config</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-MakeMakefile">
    <h1 id="module-MakeMakefile" class="module">
      module MakeMakefile
    </h1>

    <section class="description">
    
<p>mkmf.rb is used by Ruby C extensions to generate a Makefile which will correctly compile and link the C extension to Ruby and a third-party library.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="ASSEMBLE_C">ASSEMBLE_C
          <dd><p>Command which will translate C files to assembler sources in the generated Makefile</p>
          <dt id="ASSEMBLE_CXX">ASSEMBLE_CXX
          <dd><p>Command which will translate C++ files to assembler sources in the generated Makefile</p>
          <dt id="CLEANINGS">CLEANINGS
          <dd><p>Makefile rules that will clean the extension build directory</p>
          <dt id="COMMON_HEADERS">COMMON_HEADERS
          <dd><p>Common headers for Ruby C extensions</p>
          <dt id="COMMON_LIBS">COMMON_LIBS
          <dd><p>Common libraries for Ruby C extensions</p>
          <dt id="COMPILE_C">COMPILE_C
          <dd><p>Command which will compile C files in the generated Makefile</p>
          <dt id="COMPILE_CXX">COMPILE_CXX
          <dd><p>Command which will compile C++ files in the generated Makefile</p>
          <dt id="COMPILE_RULES">COMPILE_RULES
          <dd><p>make compile rules</p>
          <dt id="CONFIG">CONFIG
          <dd><p>The makefile configuration using the defaults from when Ruby was built.</p>
          <dt id="CONFTEST_CXX">CONFTEST_CXX
          <dd>
          <dt id="CXX_EXT">CXX_EXT
          <dd><p>Extensions for files compiled with a C++ compiler</p>
          <dt id="C_EXT">C_EXT
          <dd><p>Extensions for files compiled with a C compiler</p>
          <dt id="EXPORT_PREFIX">EXPORT_PREFIX
          <dd>
          <dt id="HDR_EXT">HDR_EXT
          <dd><p>Extensions for header files</p>
          <dt id="LIBARG">LIBARG
          <dd><p>Argument which will add a library to the linker</p>
          <dt id="LIBPATHFLAG">LIBPATHFLAG
          <dd><p>Argument which will add a library path to the linker</p>
          <dt id="LINK_SO">LINK_SO
          <dd><p>Command which will link a shared library</p>
          <dt id="MAIN_DOES_NOTHING">MAIN_DOES_NOTHING
          <dd><p>A C main function which does no work</p>
          <dt id="ORIG_LIBPATH">ORIG_LIBPATH
          <dd>
          <dt id="RPATHFLAG">RPATHFLAG
          <dd>
          <dt id="RULE_SUBST">RULE_SUBST
          <dd>
          <dt id="SRC_EXT">SRC_EXT
          <dd><p>Extensions for source files</p>
          <dt id="TRY_LINK">TRY_LINK
          <dd><p>Command which will compile a program in order to test linking a library</p>
          <dt id="TRY_LINK_CXX">TRY_LINK_CXX
          <dd>
          <dt id="UNIVERSAL_INTS">UNIVERSAL_INTS
          <dd>
        </dl>
        </section>



                <section id="private-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Class Methods</h3>
                </header>

                  <div id="method-c-5B-5D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">[]</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2839</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-ivar">@lang</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">name</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-5B-5D-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">[]=</span><span
                                class="method-args">(name, mod)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="5B-5D-3D-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2843</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">[]=</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">mod</span>)
  <span class="ruby-ivar">@lang</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">mod</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-append_cflags" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">append_cflags</span><span
                                class="method-args">(flags, *opts)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Check whether each given C compiler flag is acceptable and append it to <code>$CFLAGS</code> if so.</p>
<dl class="rdoc-list label-list"><dt><code>flags</code>
<dd>
<p>a C compiler flag as a <code>String</code> or an <code>Array</code> of them</p>
</dd></dl>

                              <div class="method-source-code" id="append_cflags-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1015</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">append_cflags</span>(<span class="ruby-identifier">flags</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>)
  <span class="ruby-constant">Array</span>(<span class="ruby-identifier">flags</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">flag</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">checking_for</span>(<span class="ruby-node">&quot;whether #{flag} is accepted as CFLAGS&quot;</span>) {
         <span class="ruby-identifier">try_cflags</span>(<span class="ruby-identifier">flag</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>)
       }
      <span class="ruby-identifier">$CFLAGS</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">flag</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_signedness" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_signedness</span><span
                                class="method-args">(type, headers = nil, opts = nil, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the signedness of the given <code>type</code>.  You may optionally specify additional <code>headers</code> to search in for the <code>type</code>.</p>

<p>If the <code>type</code> is found and is a numeric type, a macro is passed as a preprocessor constant to the compiler using the <code>type</code> name, in uppercase, prepended with <code>SIGNEDNESS_OF_</code>, followed by the <code>type</code> name, followed by <code>=X</code> where “X” is positive integer if the <code>type</code> is unsigned and a negative integer if the <code>type</code> is signed.</p>

<p>For example, if <code>size_t</code> is defined as unsigned, then <code>check_signedness(&#39;size_t&#39;)</code> would return +1 and the <code>SIGNEDNESS_OF_SIZE_T=+1</code> preprocessor macro would be passed to the compiler.  The <code>SIGNEDNESS_OF_INT=-1</code> macro would be set for <code>check_signedness(&#39;int&#39;)</code></p>

                              <div class="method-source-code" id="check_signedness-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1416</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_signedness</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opts</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">typedef</span>, <span class="ruby-identifier">member</span>, <span class="ruby-identifier">prelude</span> = <span class="ruby-identifier">typedef_expr</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span>)
  <span class="ruby-identifier">signed</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">checking_for</span>(<span class="ruby-node">&quot;signedness of #{type}&quot;</span>, <span class="ruby-constant">STRING_OR_FAILED_FORMAT</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">signed</span> = <span class="ruby-identifier">try_signedness</span>(<span class="ruby-identifier">typedef</span>, <span class="ruby-identifier">member</span>, [<span class="ruby-identifier">prelude</span>], <span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>) <span class="ruby-keyword">or</span> <span class="ruby-keyword">next</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-string">&quot;-DSIGNEDNESS_OF_%s=%+d&quot;</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">type</span>.<span class="ruby-identifier">tr_cpp</span>, <span class="ruby-identifier">signed</span>])
    <span class="ruby-identifier">signed</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;signed&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;unsigned&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">signed</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_sizeof" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_sizeof</span><span
                                class="method-args">(type, headers = nil, opts = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the size of the given <code>type</code>.  You may optionally specify additional <code>headers</code> to search in for the <code>type</code>.</p>

<p>If found, a macro is passed as a preprocessor constant to the compiler using the type name, in uppercase, prepended with <code>SIZEOF_</code>, followed by the type name, followed by <code>=X</code> where “X” is the actual size.</p>

<p>For example, if <code>check_sizeof(&#39;mystruct&#39;)</code> returned 12, then the <code>SIZEOF_MYSTRUCT=12</code> preprocessor macro would be passed to the compiler.</p>

                              <div class="method-source-code" id="check_sizeof-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1387</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_sizeof</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opts</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">typedef</span>, <span class="ruby-identifier">member</span>, <span class="ruby-identifier">prelude</span> = <span class="ruby-identifier">typedef_expr</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span>)
  <span class="ruby-identifier">prelude</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{typedef} *rbcv_ptr_;\n&quot;</span>
  <span class="ruby-identifier">prelude</span> = [<span class="ruby-identifier">prelude</span>]
  <span class="ruby-identifier">expr</span> = <span class="ruby-node">&quot;sizeof((*rbcv_ptr_)#{&quot;.&quot; &lt;&lt; member if member})&quot;</span>
  <span class="ruby-identifier">fmt</span> = <span class="ruby-constant">STRING_OR_FAILED_FORMAT</span>
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-node">&quot;size of #{type}&quot;</span>, <span class="ruby-identifier">headers</span>), <span class="ruby-identifier">fmt</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> = <span class="ruby-identifier">try_constant</span>(<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">prelude</span>, <span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
      <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DSIZEOF_%s=%s&quot;</span>, <span class="ruby-identifier">type</span>.<span class="ruby-identifier">tr_cpp</span>, <span class="ruby-identifier">size</span>))
      <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-convertible_int" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">convertible_int</span><span
                                class="method-args">(type, headers = nil, opts = nil, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the convertible integer type of the given <code>type</code>.  You may optionally specify additional <code>headers</code> to search in for the <code>type</code>. <em>convertible</em> means actually the same type, or typedef’d from the same type.</p>

<p>If the <code>type</code> is an integer type and the <em>convertible</em> type is found, the following macros are passed as preprocessor constants to the compiler using the <code>type</code> name, in uppercase.</p>
<ul><li>
<p><code>TYPEOF_</code>, followed by the <code>type</code> name, followed by <code>=X</code> where “X” is the found <em>convertible</em> type name.</p>
</li><li>
<p><code>TYP2NUM</code> and <code>NUM2TYP</code>, where <code>TYP</code> is the <code>type</code> name in uppercase with replacing an <code>_t</code> suffix with “T”, followed by <code>=X</code> where “X” is the macro name to convert <code>type</code> to an Integer object, and vice versa.</p>
</li></ul>

<p>For example, if <code>foobar_t</code> is defined as unsigned long, then <code>convertible_int(&quot;foobar_t&quot;)</code> would return “unsigned long”, and define these macros:</p>

<pre class="ruby"><span class="ruby-comment">#define TYPEOF_FOOBAR_T unsigned long</span>
<span class="ruby-comment">#define FOOBART2NUM ULONG2NUM</span>
<span class="ruby-comment">#define NUM2FOOBART NUM2ULONG</span>
</pre>

                              <div class="method-source-code" id="convertible_int-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1451</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">convertible_int</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opts</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">type</span>, <span class="ruby-identifier">macname</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">type</span>
  <span class="ruby-identifier">checking_for</span>(<span class="ruby-node">&quot;convertible type of #{type}&quot;</span>, <span class="ruby-constant">STRING_OR_FAILED_FORMAT</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">UNIVERSAL_INTS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>)
      <span class="ruby-identifier">type</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">typedef</span>, <span class="ruby-identifier">member</span>, <span class="ruby-identifier">prelude</span> = <span class="ruby-identifier">typedef_expr</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">member</span>
        <span class="ruby-identifier">prelude</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;static rbcv_typedef_ rbcv_var;&quot;</span>
        <span class="ruby-identifier">compat</span> = <span class="ruby-constant">UNIVERSAL_INTS</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">try_static_assert</span>(<span class="ruby-node">&quot;sizeof(rbcv_var.#{member}) == sizeof(#{t})&quot;</span>, [<span class="ruby-identifier">prelude</span>], <span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
        }
      <span class="ruby-keyword">else</span>
        <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">signed</span> = <span class="ruby-identifier">try_signedness</span>(<span class="ruby-identifier">typedef</span>, <span class="ruby-identifier">member</span>, [<span class="ruby-identifier">prelude</span>])
        <span class="ruby-identifier">u</span> = <span class="ruby-string">&quot;unsigned &quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">signed</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
        <span class="ruby-identifier">prelude</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;extern rbcv_typedef_ foo();&quot;</span>
        <span class="ruby-identifier">compat</span> = <span class="ruby-constant">UNIVERSAL_INTS</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">try_compile</span>([<span class="ruby-identifier">prelude</span>, <span class="ruby-node">&quot;extern #{u}#{t} foo();&quot;</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>), <span class="ruby-identifier">opts</span>, <span class="ruby-value">:werror</span><span class="ruby-operator">=&gt;</span><span class="ruby-keyword">true</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
        }
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">compat</span>
        <span class="ruby-identifier">macname</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/_(?=t\z)/</span>, <span class="ruby-string">&#39;&#39;</span>).<span class="ruby-identifier">tr_cpp</span>
        <span class="ruby-identifier">conv</span> = (<span class="ruby-identifier">compat</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;long long&quot;</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;LL&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">compat</span>.<span class="ruby-identifier">upcase</span>)
        <span class="ruby-identifier">compat</span> = <span class="ruby-node">&quot;#{u}#{compat}&quot;</span>
        <span class="ruby-identifier">typename</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">tr_cpp</span>
        <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DSIZEOF_%s=SIZEOF_%s&quot;</span>, <span class="ruby-identifier">typename</span>, <span class="ruby-identifier">compat</span>.<span class="ruby-identifier">tr_cpp</span>))
        <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DTYPEOF_%s=%s&quot;</span>, <span class="ruby-identifier">typename</span>, <span class="ruby-identifier">compat</span>.<span class="ruby-identifier">quote</span>))
        <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DPRI_%s_PREFIX=PRI_%s_PREFIX&quot;</span>, <span class="ruby-identifier">macname</span>, <span class="ruby-identifier">conv</span>))
        <span class="ruby-identifier">conv</span> = (<span class="ruby-identifier">u</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;U&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">conv</span>
        <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-D%s2NUM=%s2NUM&quot;</span>, <span class="ruby-identifier">macname</span>, <span class="ruby-identifier">conv</span>))
        <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DNUM2%s=NUM2%s&quot;</span>, <span class="ruby-identifier">macname</span>, <span class="ruby-identifier">conv</span>))
        <span class="ruby-identifier">compat</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-create_header" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create_header</span><span
                                class="method-args">(header = &quot;extconf.h&quot;)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Generates a header file consisting of the various macro definitions generated by other methods such as <a href="MakeMakefile.html#method-i-have_func"><code>have_func</code></a> and have_header. These are then wrapped in a custom <code>#ifndef</code> based on the <code>header</code> file name, which defaults to “extconf.h”.</p>

<p>For example:</p>

<pre class="ruby"><span class="ruby-comment"># extconf.rb</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;mkmf&#39;</span>
<span class="ruby-identifier">have_func</span>(<span class="ruby-string">&#39;realpath&#39;</span>)
<span class="ruby-identifier">have_header</span>(<span class="ruby-string">&#39;sys/utime.h&#39;</span>)
<span class="ruby-identifier">create_header</span>
<span class="ruby-identifier">create_makefile</span>(<span class="ruby-string">&#39;foo&#39;</span>)
</pre>

<p>The above script would generate the following extconf.h file:</p>

<pre class="ruby"><span class="ruby-comment">#ifndef EXTCONF_H</span>
<span class="ruby-comment">#define EXTCONF_H</span>
<span class="ruby-comment">#define HAVE_REALPATH 1</span>
<span class="ruby-comment">#define HAVE_SYS_UTIME_H 1</span>
<span class="ruby-comment">#endif</span>
</pre>

<p>Given that the <a href="MakeMakefile.html#method-i-create_header"><code>create_header</code></a> method generates a file based on definitions set earlier in your extconf.rb file, you will probably want to make this one of the last methods you call in your script.</p>

                              <div class="method-source-code" id="create_header-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1743</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_header</span>(<span class="ruby-identifier">header</span> = <span class="ruby-string">&quot;extconf.h&quot;</span>)
  <span class="ruby-identifier">message</span> <span class="ruby-string">&quot;creating %s\n&quot;</span>, <span class="ruby-identifier">header</span>
  <span class="ruby-identifier">sym</span> = <span class="ruby-identifier">header</span>.<span class="ruby-identifier">tr_cpp</span>
  <span class="ruby-identifier">hdr</span> = [<span class="ruby-node">&quot;#ifndef #{sym}\n#define #{sym}\n&quot;</span>]
  <span class="ruby-keyword">for</span> <span class="ruby-identifier">line</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">$defs</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^-D([^=]+)(?:=(.*))?/</span>
      <span class="ruby-identifier">hdr</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#define #$1 #{$2 ? Shellwords.shellwords($2)[0].gsub(/(?=\t+)/, &quot;\\\n&quot;) : 1}\n&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^-U(.*)/</span>
      <span class="ruby-identifier">hdr</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;#undef #$1\n&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">hdr</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;#endif\n&quot;</span>
  <span class="ruby-identifier">hdr</span> = <span class="ruby-identifier">hdr</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;&quot;</span>)
  <span class="ruby-identifier">log_src</span>(<span class="ruby-identifier">hdr</span>, <span class="ruby-node">&quot;#{header} is&quot;</span>)
  <span class="ruby-keyword">unless</span> (<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">header</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">hdr</span> <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">false</span>)
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">header</span>, <span class="ruby-string">&quot;wb&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hfile</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">hfile</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">hdr</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">$extconf_h</span> = <span class="ruby-identifier">header</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-create_makefile" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create_makefile</span><span
                                class="method-args">(target, srcprefix = nil) { |conf| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Generates the Makefile for your extension, passing along any options and preprocessor constants that you may have generated through other methods.</p>

<p>The <code>target</code> name should correspond the name of the global function name defined within your C extension, minus the <code>Init_</code>.  For example, if your C extension is defined as <code>Init_foo</code>, then your target would simply be “foo”.</p>

<p>If any “/” characters are present in the target name, only the last name is interpreted as the target name, and the rest are considered toplevel directory names, and the generated Makefile will be altered accordingly to follow that directory structure.</p>

<p>For example, if you pass “test/foo” as a target name, your extension will be installed under the “test” directory.  This means that in order to load the file within a Ruby program later, that directory structure will have to be followed, e.g. <code>require &#39;test/foo&#39;</code>.</p>

<p>The <code>srcprefix</code> should be used when your source files are not in the same directory as your build script. This will not only eliminate the need for you to manually copy the source files into the same directory as your build script, but it also sets the proper <code>target_prefix</code> in the generated Makefile.</p>

<p>Setting the <code>target_prefix</code> will, in turn, install the generated binary in a directory under your <code>RbConfig::CONFIG[&#39;sitearchdir&#39;]</code> that mimics your local filesystem when you run <code>make install</code>.</p>

<p>For example, given the following file tree:</p>

<pre class="ruby"><span class="ruby-identifier">ext</span><span class="ruby-operator">/</span>
  <span class="ruby-identifier">extconf</span>.<span class="ruby-identifier">rb</span>
  <span class="ruby-identifier">test</span><span class="ruby-operator">/</span>
    <span class="ruby-identifier">foo</span>.<span class="ruby-identifier">c</span>
</pre>

<p>And given the following code:</p>

<pre class="ruby"><span class="ruby-identifier">create_makefile</span>(<span class="ruby-string">&#39;test/foo&#39;</span>, <span class="ruby-string">&#39;test&#39;</span>)
</pre>

<p>That will set the <code>target_prefix</code> in the generated Makefile to “test”. That, in turn, will create the following file tree when installed via the <code>make install</code> command:</p>

<pre>/path/to/ruby/sitearchdir/test/foo.so</pre>

<p>It is recommended that you use this approach to generate your makefiles, instead of copying files around manually, because some third party libraries may depend on the <code>target_prefix</code> being set properly.</p>

<p>The <code>srcprefix</code> argument can be used to override the default source directory, i.e. the current directory.  It is included as part of the <code>VPATH</code> and added to the list of <code>INCFLAGS</code>.</p>

                              <div class="method-source-code" id="create_makefile-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2266</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_makefile</span>(<span class="ruby-identifier">target</span>, <span class="ruby-identifier">srcprefix</span> = <span class="ruby-keyword">nil</span>)
    <span class="ruby-identifier">$target</span> = <span class="ruby-identifier">target</span>
    <span class="ruby-identifier">libpath</span> = <span class="ruby-identifier">$DEFLIBPATH</span><span class="ruby-operator">|</span><span class="ruby-identifier">$LIBPATH</span>
    <span class="ruby-identifier">message</span> <span class="ruby-string">&quot;creating Makefile\n&quot;</span>
    <span class="ruby-constant">MakeMakefile</span>.<span class="ruby-identifier">rm_f</span> <span class="ruby-node">&quot;#{CONFTEST}*&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">CONFIG</span>[<span class="ruby-string">&quot;DLEXT&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">$OBJEXT</span>
      <span class="ruby-keyword">for</span> <span class="ruby-identifier">lib</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">libs</span> = <span class="ruby-identifier">$libs</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39; &#39;</span>)
        <span class="ruby-identifier">lib</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/-l(.*)/</span>, <span class="ruby-node">%%&quot;lib\\1.#{$LIBEXT}&quot;%</span>)
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DEXTLIB=&#39;%s&#39;&quot;</span>, <span class="ruby-identifier">libs</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;,&quot;</span>)))
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">target</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;/&#39;</span>)
      <span class="ruby-identifier">target_prefix</span>, <span class="ruby-identifier">target</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">target</span>)
      <span class="ruby-identifier">target_prefix</span>[<span class="ruby-value">0</span>,<span class="ruby-value">0</span>] = <span class="ruby-string">&#39;/&#39;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">target_prefix</span> = <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">srcprefix</span> <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;$(srcdir)/#{srcprefix}&quot;</span>.<span class="ruby-identifier">chomp</span>(<span class="ruby-string">&#39;/&#39;</span>)
    <span class="ruby-constant">RbConfig</span>.<span class="ruby-identifier">expand</span>(<span class="ruby-identifier">srcdir</span> = <span class="ruby-identifier">srcprefix</span>.<span class="ruby-identifier">dup</span>)

    <span class="ruby-identifier">ext</span> = <span class="ruby-node">&quot;.#{$OBJEXT}&quot;</span>
    <span class="ruby-identifier">orig_srcs</span> = <span class="ruby-constant">Dir</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">srcdir</span>, <span class="ruby-node">&quot;*.{#{SRC_EXT.join(%q{,})}}&quot;</span>)]
    <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">$objs</span>
      <span class="ruby-identifier">srcs</span> = <span class="ruby-identifier">$srcs</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">orig_srcs</span>
      <span class="ruby-identifier">$objs</span> = []
      <span class="ruby-identifier">objs</span> = <span class="ruby-identifier">srcs</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> {[]}) {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">h</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">o</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">f</span>, <span class="ruby-string">&quot;.*&quot;</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ext</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">$objs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">o</span>
        <span class="ruby-identifier">h</span>[<span class="ruby-identifier">o</span>] <span class="ruby-operator">&lt;&lt;=</span> <span class="ruby-identifier">f</span>
        <span class="ruby-identifier">h</span>
      }
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">objs</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span>, <span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>}.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">dups</span> = <span class="ruby-identifier">objs</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span>, <span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
          <span class="ruby-node">&quot;#{b[/.*\./]}{#{f.collect {|n| n[/([^.]+)\z/]}.join(&#39;,&#39;)}}&quot;</span>
        }
        <span class="ruby-identifier">abort</span> <span class="ruby-node">&quot;source files duplication - #{dups.join(&quot;, &quot;)}&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">$objs</span>.<span class="ruby-identifier">collect!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">o</span>, <span class="ruby-string">&quot;.*&quot;</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ext</span>} <span class="ruby-keyword">unless</span> <span class="ruby-identifier">$OBJEXT</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;o&quot;</span>
      <span class="ruby-identifier">srcs</span> = <span class="ruby-identifier">$srcs</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">$objs</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">chomp</span>(<span class="ruby-identifier">ext</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;.c&quot;</span>}
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">$srcs</span> = <span class="ruby-identifier">srcs</span>

    <span class="ruby-identifier">hdrs</span> = <span class="ruby-constant">Dir</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">srcdir</span>, <span class="ruby-node">&quot;*.{#{HDR_EXT.join(%q{,})}}&quot;</span>)]

    <span class="ruby-identifier">target</span> = <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">$objs</span>.<span class="ruby-identifier">empty?</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">target</span> <span class="ruby-keyword">and</span> <span class="ruby-constant">EXPORT_PREFIX</span>
      <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">srcdir</span>, <span class="ruby-identifier">target</span> <span class="ruby-operator">+</span> <span class="ruby-string">&#39;.def&#39;</span>))
        <span class="ruby-identifier">deffile</span> = <span class="ruby-string">&quot;$(srcdir)/$(TARGET).def&quot;</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-constant">EXPORT_PREFIX</span>.<span class="ruby-identifier">empty?</span>
          <span class="ruby-identifier">makedef</span> = <span class="ruby-node">%{$(RUBY) -pe &quot;$$_.sub!(/^(?=\\w)/,&#39;#{EXPORT_PREFIX}&#39;) unless 1../^EXPORTS$/i&quot; #{deffile}}</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">makedef</span> = <span class="ruby-string">%{(echo EXPORTS &amp;&amp; echo $(TARGET_ENTRY))}</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">makedef</span>
        <span class="ruby-identifier">$cleanfiles</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;$(DEFFILE)&#39;</span>
        <span class="ruby-identifier">origdef</span> = <span class="ruby-identifier">deffile</span>
        <span class="ruby-identifier">deffile</span> = <span class="ruby-string">&quot;$(TARGET)-$(arch).def&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">origdef</span> <span class="ruby-operator">||=</span> <span class="ruby-string">&#39;&#39;</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extout</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">$INSTALLFILES</span>
      <span class="ruby-identifier">$cleanfiles</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">$INSTALLFILES</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">files</span>, <span class="ruby-identifier">dir</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">files</span>.<span class="ruby-identifier">delete_prefix</span>(<span class="ruby-string">&#39;./&#39;</span>))})
      <span class="ruby-identifier">$distcleandirs</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">$INSTALLFILES</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">files</span>, <span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dir</span>})
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extmk</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">$static</span>
      <span class="ruby-identifier">$defs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;-DRUBY_EXPORT=1&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extmk</span> <span class="ruby-keyword">and</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">$extconf_h</span>
      <span class="ruby-identifier">create_header</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">libpath</span> = <span class="ruby-identifier">libpathflag</span>(<span class="ruby-identifier">libpath</span>)

    <span class="ruby-identifier">dllib</span> = <span class="ruby-identifier">target</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;$(TARGET).#{CONFIG[&#39;DLEXT&#39;]}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-identifier">staticlib</span> = <span class="ruby-identifier">target</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;$(TARGET).#$LIBEXT&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">srcprefix</span>)
    <span class="ruby-identifier">conf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;\
libpath = #{($DEFLIBPATH|$LIBPATH).join(&quot; &quot;)}
LIBPATH = #{libpath}
DEFFILE = #{deffile}

CLEANFILES = #{$cleanfiles.join(&#39; &#39;)}
DISTCLEANFILES = #{$distcleanfiles.join(&#39; &#39;)}
DISTCLEANDIRS = #{$distcleandirs.join(&#39; &#39;)}

extout = #{$extout &amp;&amp; $extout.quote}
extout_prefix = #{$extout_prefix}
target_prefix = #{target_prefix}
LOCAL_LIBS = #{$LOCAL_LIBS}
LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS}
ORIG_SRCS = #{orig_srcs.collect(&amp;File.method(:basename)).join(&#39; &#39;)}
SRCS = $(ORIG_SRCS) #{(srcs - orig_srcs).collect(&amp;File.method(:basename)).join(&#39; &#39;)}
OBJS = #{$objs.join(&quot; &quot;)}
HDRS = #{hdrs.map{|h| &#39;$(srcdir)/&#39; + File.basename(h)}.join(&#39; &#39;)}
LOCAL_HDRS = #{$headers.join(&#39; &#39;)}
TARGET = #{target}
TARGET_NAME = #{target &amp;&amp; target[/\A\w+/]}
TARGET_ENTRY = #{EXPORT_PREFIX || &#39;&#39;}Init_$(TARGET_NAME)
DLLIB = #{dllib}
EXTSTATIC = #{$static || &quot;&quot;}
STATIC_LIB = #{staticlib unless $static.nil?}
#{!$extout &amp;&amp; defined?($installed_list) ? &quot;INSTALLED_LIST = #{$installed_list}\n&quot; : &quot;&quot;}
TIMESTAMP_DIR = #{$extout &amp;&amp; $extmk ? &#39;$(extout)/.timestamp&#39; : &#39;.&#39;}
&quot;</span> <span class="ruby-comment">#&quot;</span>
    <span class="ruby-comment"># TODO: fixme</span>
    <span class="ruby-identifier">install_dirs</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">conf</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-string">&quot;%-14s= %s\n&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">d</span>) <span class="ruby-keyword">if</span> <span class="ruby-regexp">/^[[:upper:]]/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">d</span>[<span class="ruby-value">0</span>]}
    <span class="ruby-identifier">sodir</span> = <span class="ruby-identifier">$extout</span> <span class="ruby-operator">?</span> <span class="ruby-string">&#39;$(TARGET_SO_DIR)&#39;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;$(RUBYARCHDIR)&#39;</span>
    <span class="ruby-identifier">n</span> = <span class="ruby-string">&#39;$(TARGET_SO_DIR)$(TARGET)&#39;</span>
    <span class="ruby-identifier">cleanobjs</span> = [<span class="ruby-string">&quot;$(OBJS)&quot;</span>]
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extmk</span>
      <span class="ruby-node">%w[bc i s]</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ex</span><span class="ruby-operator">|</span> <span class="ruby-identifier">cleanobjs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;$(OBJS:.#{$OBJEXT}=.#{ex})&quot;</span>}
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">target</span>
      <span class="ruby-identifier">config_string</span>(<span class="ruby-string">&#39;cleanobjs&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">cleanobjs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\$\*/</span>, <span class="ruby-node">&quot;$(TARGET)#{deffile ? &#39;-$(arch)&#39;: &#39;&#39;}&quot;</span>)}
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">conf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;\
TARGET_SO_DIR =#{$extout ? &quot; $(RUBYARCHDIR)/&quot; : &#39;&#39;}
TARGET_SO     = $(TARGET_SO_DIR)$(DLLIB)
CLEANLIBS     = #{&#39;$(TARGET_SO) &#39; if target}#{config_string(&#39;cleanlibs&#39;) {|t| t.gsub(/\$\*/) {n}}}
CLEANOBJS     = #{cleanobjs.join(&#39; &#39;)} *.bak
TARGET_SO_DIR_TIMESTAMP = #{timestamp_file(sodir, target_prefix)}
&quot;</span> <span class="ruby-comment">#&quot;</span>

    <span class="ruby-identifier">conf</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">conf</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-identifier">mfile</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">&quot;Makefile&quot;</span>, <span class="ruby-string">&quot;wb&quot;</span>)
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">conf</span>)
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;
all:    #{$extout ? &quot;install&quot; : target ? &quot;$(DLLIB)&quot; : &quot;Makefile&quot;}
static: #{$extmk &amp;&amp; !$static ? &quot;all&quot; : &quot;$(STATIC_LIB)#{$extout ? &quot; install-rb&quot; : &quot;&quot;}&quot;}
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-static clean-rb
&quot;</span> <span class="ruby-comment">#&quot;</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-constant">CLEANINGS</span>
    <span class="ruby-identifier">fsep</span> = <span class="ruby-identifier">config_string</span>(<span class="ruby-string">&#39;BUILD_FILE_SEPARATOR&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;/&quot;</span>}
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">fsep</span>
      <span class="ruby-identifier">sep</span> = <span class="ruby-node">&quot;:/=#{fsep}&quot;</span>
      <span class="ruby-identifier">fseprepl</span> = <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">s</span> = <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">&quot;/&quot;</span>, <span class="ruby-identifier">fsep</span>)
        <span class="ruby-identifier">s</span> = <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(\$\(\w+)(\))/</span>) {<span class="ruby-node">$1</span><span class="ruby-operator">+</span><span class="ruby-identifier">sep</span><span class="ruby-operator">+</span><span class="ruby-node">$2</span>}
        <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(\$\{\w+)(\})/</span>) {<span class="ruby-node">$1</span><span class="ruby-operator">+</span><span class="ruby-identifier">sep</span><span class="ruby-operator">+</span><span class="ruby-node">$2</span>}
      }
      <span class="ruby-identifier">rsep</span> = <span class="ruby-node">&quot;:#{fsep}=/&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">fseprepl</span> = <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>}
      <span class="ruby-identifier">sep</span> = <span class="ruby-string">&quot;&quot;</span>
      <span class="ruby-identifier">rsep</span> = <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">dirs</span> = []
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;install: install-so install-rb\n\n&quot;</span>
    <span class="ruby-identifier">dir</span> = <span class="ruby-identifier">sodir</span>.<span class="ruby-identifier">dup</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;install-so: &quot;</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">target</span>
      <span class="ruby-identifier">f</span> = <span class="ruby-string">&quot;$(DLLIB)&quot;</span>
      <span class="ruby-identifier">dest</span> = <span class="ruby-string">&quot;$(TARGET_SO)&quot;</span>
      <span class="ruby-identifier">stamp</span> = <span class="ruby-string">&#39;$(TARGET_SO_DIR_TIMESTAMP)&#39;</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extout</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">dest</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;clean-so::\n&quot;</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t-$(Q)$(RM) #{fseprepl[dest]} #{fseprepl[stamp]}\n&quot;</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t-$(Q)$(RMDIRS) #{fseprepl[dir]}#{$ignore_error}\n&quot;</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;#{f} #{stamp}\n&quot;</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t$(INSTALL_PROG) #{fseprepl[f]} #{dir}\n&quot;</span>
        <span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-identifier">$installed_list</span>)
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t@echo #{dir}/#{File.basename(f)}&gt;&gt;$(INSTALLED_LIST)\n&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;clean-static::\n&quot;</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;\t-$(Q)$(RM) $(STATIC_LIB)\n&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Makefile&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;install-rb: pre-install-rb do-install-rb install-rb-default\n&quot;</span>)
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;install-rb-default: pre-install-rb-default do-install-rb-default\n&quot;</span>)
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;pre-install-rb: Makefile\n&quot;</span>)
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;pre-install-rb-default: Makefile\n&quot;</span>)
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;do-install-rb:\n&quot;</span>)
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;do-install-rb-default:\n&quot;</span>)
    <span class="ruby-keyword">for</span> <span class="ruby-identifier">sfx</span>, <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> [[<span class="ruby-string">&quot;-default&quot;</span>, [[<span class="ruby-string">&quot;lib/**/*.rb&quot;</span>, <span class="ruby-string">&quot;$(RUBYLIBDIR)&quot;</span>, <span class="ruby-string">&quot;lib&quot;</span>]]], [<span class="ruby-string">&quot;&quot;</span>, <span class="ruby-identifier">$INSTALLFILES</span>]]
      <span class="ruby-identifier">files</span> = <span class="ruby-identifier">install_files</span>(<span class="ruby-identifier">mfile</span>, <span class="ruby-identifier">i</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">srcprefix</span>) <span class="ruby-keyword">or</span> <span class="ruby-keyword">next</span>
      <span class="ruby-keyword">for</span> <span class="ruby-identifier">dir</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">files</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">files</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">dir</span>)
          <span class="ruby-identifier">dirs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">dir</span>
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;pre-install-rb#{sfx}: #{timestamp_file(dir, target_prefix)}\n&quot;</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">for</span> <span class="ruby-identifier">f</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">files</span>
          <span class="ruby-identifier">dest</span> = <span class="ruby-node">&quot;#{dir}/#{File.basename(f)}&quot;</span>
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;do-install-rb#{sfx}: #{dest}\n&quot;</span>)
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;#{dest}: #{f} #{timestamp_file(dir, target_prefix)}\n&quot;</span>)
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;\t$(Q) $(#{$extout ? &#39;COPY&#39; : &#39;INSTALL_DATA&#39;}) #{f} $(@D)\n&quot;</span>)
          <span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-identifier">$installed_list</span>) <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">$extout</span>
            <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;\t@echo #{dest}&gt;&gt;$(INSTALLED_LIST)\n&quot;</span>)
          <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extout</span>
            <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;clean-rb#{sfx}::\n&quot;</span>)
            <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;\t-$(Q)$(RM) #{fseprepl[dest]}\n&quot;</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;pre-install-rb#{sfx}:\n&quot;</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">files</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;\t@$(NULLCMD)\n&quot;</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">q</span> = <span class="ruby-node">&quot;$(MAKE) -q do-install-rb#{sfx}&quot;</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">$nmake</span>
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;!if \&quot;$(Q)\&quot; == \&quot;@\&quot;\n\t@#{q} || \\\n!endif\n\t&quot;</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t$(Q1:0=@#{q} || )&quot;</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;$(ECHO1:0=echo) installing#{sfx.sub(/^-/, &quot; &quot;)} #{target} libraries\n&quot;</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extout</span>
        <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">uniq!</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">empty?</span>
          <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;clean-rb#{sfx}::\n&quot;</span>)
          <span class="ruby-keyword">for</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">sort_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-operator">-</span><span class="ruby-identifier">d</span>.<span class="ruby-identifier">count</span>(<span class="ruby-string">&#39;/&#39;</span>)}
            <span class="ruby-identifier">stamp</span> = <span class="ruby-identifier">timestamp_file</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">target_prefix</span>)
            <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;\t-$(Q)$(RM) #{fseprepl[stamp]}\n&quot;</span>)
            <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-node">&quot;\t-$(Q)$(RMDIRS) #{fseprepl[dir]}#{$ignore_error}\n&quot;</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">target</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">sodir</span>)
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;$(TARGET_SO_DIR_TIMESTAMP):\n\t$(Q) $(MAKEDIRS) $(@D) #{sodir}\n\t$(Q) $(TOUCH) $@\n&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">t</span> = <span class="ruby-identifier">timestamp_file</span>(<span class="ruby-identifier">d</span>, <span class="ruby-identifier">target_prefix</span>)
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;#{t}:\n\t$(Q) $(MAKEDIRS) $(@D) #{d}\n\t$(Q) $(TOUCH) $@\n&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">&lt;&lt;-SITEINSTALL</span>
<span class="ruby-value">
site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb

</span><span class="ruby-identifier">    SITEINSTALL</span>

    <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">target</span>

    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;.SUFFIXES: .#{(SRC_EXT + [$OBJEXT, $ASMEXT]).compact.join(&#39; .&#39;)}\n&quot;</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;\n&quot;</span>

    <span class="ruby-identifier">compile_command</span> = <span class="ruby-node">&quot;\n\t$(ECHO) compiling $(&lt;#{rsep})\n\t$(Q) %s\n\n&quot;</span>
    <span class="ruby-identifier">command</span> = <span class="ruby-identifier">compile_command</span> <span class="ruby-operator">%</span> <span class="ruby-constant">COMPILE_CXX</span>
    <span class="ruby-identifier">asm_command</span> = <span class="ruby-identifier">compile_command</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/compiling/</span>, <span class="ruby-string">&#39;translating&#39;</span>) <span class="ruby-operator">%</span> <span class="ruby-constant">ASSEMBLE_CXX</span>
    <span class="ruby-constant">CXX_EXT</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">each_compile_rules</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rule</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">printf</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">e</span>, <span class="ruby-identifier">$OBJEXT</span>)
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">command</span>)
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">printf</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">e</span>, <span class="ruby-identifier">$ASMEXT</span>)
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">asm_command</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">command</span> = <span class="ruby-identifier">compile_command</span> <span class="ruby-operator">%</span> <span class="ruby-constant">COMPILE_C</span>
    <span class="ruby-identifier">asm_command</span> = <span class="ruby-identifier">compile_command</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/compiling/</span>, <span class="ruby-string">&#39;translating&#39;</span>) <span class="ruby-operator">%</span> <span class="ruby-constant">ASSEMBLE_C</span>
    <span class="ruby-constant">C_EXT</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">each_compile_rules</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rule</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">printf</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">e</span>, <span class="ruby-identifier">$OBJEXT</span>)
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">command</span>)
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">printf</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">e</span>, <span class="ruby-identifier">$ASMEXT</span>)
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">asm_command</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;$(TARGET_SO): &quot;</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;$(DEFFILE) &quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">makedef</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;$(OBJS) Makefile&quot;</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot; $(TARGET_SO_DIR_TIMESTAMP)&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extout</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;\n&quot;</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t$(ECHO) linking shared-object #{target_prefix.sub(/\A\/(.*)/, &#39;\1/&#39;)}$(DLLIB)\n&quot;</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t-$(Q)$(RM) $(@#{sep})\n&quot;</span>
    <span class="ruby-identifier">link_so</span> = <span class="ruby-constant">LINK_SO</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^/</span>, <span class="ruby-string">&quot;\t$(Q) &quot;</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">srcs</span>.<span class="ruby-identifier">any?</span>(<span class="ruby-operator">&amp;</span><span class="ruby-regexp">%r&quot;\.(?:#{CXX_EXT.join(&#39;|&#39;)})\z&quot;</span>.<span class="ruby-identifier">method</span>(<span class="ruby-value">:===</span>))
      <span class="ruby-identifier">link_so</span> = <span class="ruby-identifier">link_so</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/\bLDSHARED\b/</span>, <span class="ruby-string">&#39;\&amp;XX&#39;</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">link_so</span>, <span class="ruby-string">&quot;\n\n&quot;</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">$static</span>.<span class="ruby-identifier">nil?</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;$(STATIC_LIB): $(OBJS)\n\t-$(Q)$(RM) $(@#{sep})\n\t&quot;</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;$(ECHO) linking static-library $(@#{rsep})\n\t$(Q) &quot;</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;$(AR) #{config_string(&#39;ARFLAGS&#39;) || &#39;cru &#39;}$@ $(OBJS)&quot;</span>
      <span class="ruby-identifier">config_string</span>(<span class="ruby-string">&#39;RANLIB&#39;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ranlib</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\n\t-$(Q)#{ranlib} $(@)#{$ignore_error}&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;\n\n&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">makedef</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;$(DEFFILE): #{origdef}\n&quot;</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t$(ECHO) generating $(@#{rsep})\n&quot;</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;\t$(Q) #{makedef} &gt; $@\n\n&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">depend</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">srcdir</span>, <span class="ruby-string">&quot;depend&quot;</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">depend</span>)
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;###\n&quot;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">depend_rules</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">depend</span>)))
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">print</span> <span class="ruby-string">&quot;$(OBJS): $(HDRS) $(ruby_headers)\n&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">$makefile_created</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-identifier">mfile</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mfile</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-depend_rules" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">depend_rules</span><span
                                class="method-args">(depend)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Processes the data contents of the “depend” file.  Each line of this file is expected to be a file name.</p>

<p>Returns the output of findings, in Makefile format.</p>

                              <div class="method-source-code" id="depend_rules-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2151</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">depend_rules</span>(<span class="ruby-identifier">depend</span>)
  <span class="ruby-identifier">suffixes</span> = []
  <span class="ruby-identifier">depout</span> = []
  <span class="ruby-identifier">cont</span> = <span class="ruby-identifier">implicit</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">impconv</span> = <span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">each_compile_rules</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">rule</span><span class="ruby-operator">|</span> <span class="ruby-identifier">depout</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">rule</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">implicit</span>[<span class="ruby-value">0</span>]) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">implicit</span>[<span class="ruby-value">1</span>]}
    <span class="ruby-identifier">implicit</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ruleconv</span> = <span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">implicit</span>
      <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\A\t/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">line</span>
        <span class="ruby-identifier">implicit</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
        <span class="ruby-keyword">next</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">impconv</span>[]
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">m</span> = <span class="ruby-regexp">/\A\.(\w+)\.(\w+)(?:\s*:)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">line</span>)
      <span class="ruby-identifier">suffixes</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>]
      <span class="ruby-identifier">implicit</span> = [[<span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>]], [<span class="ruby-identifier">m</span>.<span class="ruby-identifier">post_match</span>]]
      <span class="ruby-keyword">next</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-constant">RULE_SUBST</span> <span class="ruby-keyword">and</span> <span class="ruby-regexp">/\A(?!\s*\w+\s*=)[$\w][^#]*:/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">line</span>
      <span class="ruby-identifier">line</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/\s*\#.*$/</span>, <span class="ruby-string">&#39;&#39;</span>)
      <span class="ruby-identifier">comment</span> = <span class="ruby-node">$&amp;</span>
      <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">%r&quot;(\s)(?!\.)([^$(){}+=:\s\\,]+)(?=\s|\z)&quot;</span>) {<span class="ruby-node">$1</span> <span class="ruby-operator">+</span> <span class="ruby-constant">RULE_SUBST</span> <span class="ruby-operator">%</span> <span class="ruby-node">$2</span>}
      <span class="ruby-identifier">line</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">comment</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">comment</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">depout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">depend</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\.o\b/</span>, <span class="ruby-node">&quot;.#{$OBJEXT}&quot;</span>)
    <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\{\$\(VPATH\)\}/</span>, <span class="ruby-string">&quot;&quot;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">$nmake</span>
    <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\$\((?:hdr|top)dir\)\/config.h/</span>, <span class="ruby-identifier">$config_h</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">$nmake</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-regexp">/\A\s*\$\(RM|COPY\)/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">line</span>
      <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">%r&quot;[-\w\./]{2,}&quot;</span>){<span class="ruby-node">$&amp;</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-string">&quot;/&quot;</span>, <span class="ruby-string">&quot;\\&quot;</span>)}
      <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/(\$\((?!RM|COPY)[^:)]+)(?=\))/</span>, <span class="ruby-string">&#39;\1:/=\\&#39;</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-regexp">/(?:^|[^\\])(?:\\\\)*\\$/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">line</span>
      (<span class="ruby-identifier">cont</span> <span class="ruby-operator">||=</span> []) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
      <span class="ruby-keyword">next</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">cont</span>
      <span class="ruby-identifier">line</span> = (<span class="ruby-identifier">cont</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>).<span class="ruby-identifier">join</span>
      <span class="ruby-identifier">cont</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">ruleconv</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">line</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">cont</span>
    <span class="ruby-identifier">ruleconv</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">cont</span>.<span class="ruby-identifier">join</span>)
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">implicit</span>
    <span class="ruby-identifier">impconv</span>.<span class="ruby-identifier">call</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">suffixes</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">depout</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-string">&quot;.SUFFIXES: .&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">suffixes</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot; .&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n\n&quot;</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">$extconf_h</span>
    <span class="ruby-identifier">depout</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-string">&quot;$(OBJS): $(RUBY_EXTCONF_H)\n\n&quot;</span>)
    <span class="ruby-identifier">depout</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-string">&quot;$(OBJS): $(hdrdir)/ruby/win32.h\n\n&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">$mswin</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">$mingw</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">depout</span>.<span class="ruby-identifier">flatten!</span>
  <span class="ruby-identifier">depout</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-dir_config" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          dir_config(target)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          dir_config(target, prefix)
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          dir_config(target, idefault, ldefault)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Sets a <code>target</code> name that the user can then use to configure various “with” options with on the command line by using that name.  For example, if the target is set to “foo”, then the user could use the <code>--with-foo-dir=prefix</code>, <code>--with-foo-include=dir</code> and <code>--with-foo-lib=dir</code> command line options to tell where to search for header/library files.</p>

<p>You may pass along additional parameters to specify default values.  If one is given it is taken as default <code>prefix</code>, and if two are given they are taken as “include” and “lib” defaults in that order.</p>

<p>In any case, the return value will be an array of determined “include” and “lib” directories, either of which can be nil if no corresponding command line option is given when no default value is specified.</p>

<p>Note that <a href="MakeMakefile.html#method-i-dir_config"><code>dir_config</code></a> only adds to the list of places to search for libraries and include files.  It does not link the libraries into your application.</p>

                              <div class="method-source-code" id="dir_config-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1793</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">dir_config</span>(<span class="ruby-identifier">target</span>, <span class="ruby-identifier">idefault</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">ldefault</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">$config_dirs</span>[<span class="ruby-identifier">target</span>]
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">conf</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">dir</span> = <span class="ruby-identifier">with_config</span>(<span class="ruby-identifier">target</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;-dir&quot;</span>, (<span class="ruby-identifier">idefault</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ldefault</span>))
    <span class="ruby-identifier">defaults</span> = <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>)
    <span class="ruby-identifier">idefault</span> = <span class="ruby-identifier">ldefault</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">idir</span> = <span class="ruby-identifier">with_config</span>(<span class="ruby-identifier">target</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;-include&quot;</span>, <span class="ruby-identifier">idefault</span>)
  <span class="ruby-identifier">$arg_config</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;${#{target}-dir}/include&quot;</span>
  <span class="ruby-identifier">ldir</span> = <span class="ruby-identifier">with_config</span>(<span class="ruby-identifier">target</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;-lib&quot;</span>, <span class="ruby-identifier">ldefault</span>)
  <span class="ruby-identifier">$arg_config</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;${#{target}-dir}/#{_libdir_basename}&quot;</span>

  <span class="ruby-identifier">idirs</span> = <span class="ruby-identifier">idir</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">idir</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">idir</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">idir</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>) <span class="ruby-operator">:</span> []
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">defaults</span>
    <span class="ruby-identifier">idirs</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;/include&quot;</span>})
    <span class="ruby-identifier">idir</span> = ([<span class="ruby-identifier">idir</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">idirs</span>).<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">idirs</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">idirs</span>.<span class="ruby-identifier">collect!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-string">&quot;-I&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">d</span>}
    <span class="ruby-identifier">idirs</span> <span class="ruby-operator">-=</span> <span class="ruby-constant">Shellwords</span>.<span class="ruby-identifier">shellwords</span>(<span class="ruby-identifier">$CPPFLAGS</span>)
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">idirs</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">$CPPFLAGS</span> = (<span class="ruby-identifier">idirs</span>.<span class="ruby-identifier">quote</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">$CPPFLAGS</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot; &quot;</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">ldirs</span> = <span class="ruby-identifier">ldir</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">ldir</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">ldir</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">ldir</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>) <span class="ruby-operator">:</span> []
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">defaults</span>
    <span class="ruby-identifier">ldirs</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{d}/#{_libdir_basename}&quot;</span>})
    <span class="ruby-identifier">ldir</span> = ([<span class="ruby-identifier">ldir</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">ldirs</span>).<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">$LIBPATH</span> = <span class="ruby-identifier">ldirs</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">$LIBPATH</span>

  <span class="ruby-identifier">$config_dirs</span>[<span class="ruby-identifier">target</span>] = [<span class="ruby-identifier">idir</span>, <span class="ruby-identifier">ldir</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-dummy_makefile" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">dummy_makefile</span><span
                                class="method-args">(srcdir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a stub Makefile.</p>

                              <div class="method-source-code" id="dummy_makefile-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2120</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">dummy_makefile</span>(<span class="ruby-identifier">srcdir</span>)
    <span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">srcdir</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">&lt;&lt;RULES</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">CLEANINGS</span>
<span class="ruby-value">CLEANFILES = #{$cleanfiles.join(&#39; &#39;)}
DISTCLEANFILES = #{$distcleanfiles.join(&#39; &#39;)}

all install static install-so install-rb: Makefile
        @$(NULLCMD)
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-static clean-rb

</span><span class="ruby-identifier">RULES</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-enable_config" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">enable_config</span><span
                                class="method-args">(config, default=nil) { |config, default| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Tests for the presence of an <code>--enable-</code><em>config</em> or <code>--disable-</code><em>config</em> option. Returns <code>true</code> if the enable option is given, <code>false</code> if the disable option is given, and the default value otherwise.</p>

<p>This can be useful for adding custom definitions, such as debug information.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-keyword">if</span> <span class="ruby-identifier">enable_config</span>(<span class="ruby-string">&quot;debug&quot;</span>)
   <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-string">&quot;-DOSSL_DEBUG&quot;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;-DOSSL_DEBUG&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="enable_config-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1705</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">enable_config</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">default</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg_config</span>(<span class="ruby-string">&quot;--enable-&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">config</span>)
    <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">arg_config</span>(<span class="ruby-string">&quot;--disable-&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">config</span>)
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">default</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">default</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_executable" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_executable</span><span
                                class="method-args">(bin, path = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Searches for the executable <code>bin</code> on <code>path</code>.  The default path is your <code>PATH</code> environment variable. If that isn’t defined, it will resort to searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.</p>

<p>If found, it will return the full path, including the executable name, of where it was found.</p>

<p>Note that this method does not actually affect the generated Makefile.</p>

                              <div class="method-source-code" id="find_executable-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1635</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_executable</span>(<span class="ruby-identifier">bin</span>, <span class="ruby-identifier">path</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">bin</span>, <span class="ruby-identifier">path</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">find_executable0</span>(<span class="ruby-identifier">bin</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_header" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_header</span><span
                                class="method-args">(header, *paths)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Instructs mkmf to search for the given <code>header</code> in any of the <code>paths</code> provided, and returns whether or not it was found in those paths.</p>

<p>If the header is found then the path it was found on is added to the list of included directories that are sent to the compiler (via the <code>-I</code> switch).</p>

                              <div class="method-source-code" id="find_header-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1199</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_header</span>(<span class="ruby-identifier">header</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">paths</span>)
  <span class="ruby-identifier">message</span> = <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">paths</span>)
  <span class="ruby-identifier">header</span> = <span class="ruby-identifier">cpp_include</span>(<span class="ruby-identifier">header</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">message</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_header</span>(<span class="ruby-identifier">header</span>)
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">found</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-identifier">paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opt</span> = <span class="ruby-node">&quot;-I#{dir}&quot;</span>.<span class="ruby-identifier">quote</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_header</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">opt</span>)
          <span class="ruby-identifier">$INCFLAGS</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">opt</span>
          <span class="ruby-identifier">found</span> = <span class="ruby-keyword">true</span>
          <span class="ruby-keyword">break</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">found</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_library" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_library</span><span
                                class="method-args">(lib, func, *paths, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the entry point <code>func</code> can be found within the library <code>lib</code> in one of the <code>paths</code> specified, where <code>paths</code> is an array of strings.  If <code>func</code> is <code>nil</code> , then the <code>main()</code> function is used as the entry point.</p>

<p>If <code>lib</code> is found, then the path it was found on is added to the list of library paths searched and linked against.</p>

                              <div class="method-source-code" id="find_library-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1073</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_library</span>(<span class="ruby-identifier">lib</span>, <span class="ruby-identifier">func</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">paths</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">dir_config</span>(<span class="ruby-identifier">lib</span>)
  <span class="ruby-identifier">lib</span> = <span class="ruby-identifier">with_config</span>(<span class="ruby-identifier">lib</span><span class="ruby-string">+&#39;lib&#39;</span>, <span class="ruby-identifier">lib</span>)
  <span class="ruby-identifier">paths</span> = <span class="ruby-identifier">paths</span>.<span class="ruby-identifier">flat_map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>)}
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">func</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">func</span>.<span class="ruby-identifier">funcall_style</span>, <span class="ruby-constant">LIBARG</span><span class="ruby-operator">%</span><span class="ruby-identifier">lib</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">libpath</span> = <span class="ruby-identifier">$LIBPATH</span>
    <span class="ruby-identifier">libs</span> = <span class="ruby-identifier">append_library</span>(<span class="ruby-identifier">$libs</span>, <span class="ruby-identifier">lib</span>)
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">until</span> <span class="ruby-identifier">r</span> = <span class="ruby-identifier">try_func</span>(<span class="ruby-identifier">func</span>, <span class="ruby-identifier">libs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">paths</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">$LIBPATH</span> = <span class="ruby-identifier">libpath</span> <span class="ruby-operator">|</span> [<span class="ruby-identifier">paths</span>.<span class="ruby-identifier">shift</span>]
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">r</span>
        <span class="ruby-identifier">$libs</span> = <span class="ruby-identifier">libs</span>
        <span class="ruby-identifier">libpath</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-identifier">$LIBPATH</span> = <span class="ruby-identifier">libpath</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">libpath</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">r</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_type" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_type</span><span
                                class="method-args">(type, opt, *headers, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns where the static type <code>type</code> is defined.</p>

<p>You may also pass additional flags to <code>opt</code> which are then passed along to the compiler.</p>

<p>See also <code>have_type</code>.</p>

                              <div class="method-source-code" id="find_type-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1296</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_type</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">headers</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">opt</span> <span class="ruby-operator">||=</span> <span class="ruby-string">&quot;&quot;</span>
  <span class="ruby-identifier">fmt</span> = <span class="ruby-string">&quot;not found&quot;</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fmt</span>.<span class="ruby-identifier">%</span>(<span class="ruby-identifier">x</span>)
    <span class="ruby-identifier">x</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:join</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;,&quot;</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">type</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span>), <span class="ruby-identifier">fmt</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">find</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">try_type</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">h</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_const" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_const</span><span
                                class="method-args">(const, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the constant <code>const</code> is defined.  You may optionally pass the <code>type</code> of <code>const</code> as <code>[const, type]</code>, such as:</p>

<pre class="ruby"><span class="ruby-identifier">have_const</span>(<span class="ruby-node">%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t]</span>, <span class="ruby-string">&quot;pthread.h&quot;</span>)
</pre>

<p>You may also pass additional <code>headers</code> to check against in addition to the common header files, and additional flags to <code>opt</code> which are then passed along to the compiler.</p>

<p>If found, a macro is passed as a preprocessor constant to the compiler using the type name, in uppercase, prepended with <code>HAVE_CONST_</code>.</p>

<p>For example, if <code>have_const(&#39;foo&#39;)</code> returned true, then the <code>HAVE_CONST_FOO</code> preprocessor macro would be passed to the compiler.</p>

                              <div class="method-source-code" id="have_const-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1344</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_const</span>(<span class="ruby-identifier">const</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>([<span class="ruby-operator">*</span><span class="ruby-identifier">const</span>].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>), <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">try_const</span>(<span class="ruby-identifier">const</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_framework" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_framework</span><span
                                class="method-args">(fw, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the given <code>framework</code> can be found on your system. If found, a macro is passed as a preprocessor constant to the compiler using the framework name, in uppercase, prepended with <code>HAVE_FRAMEWORK_</code>.</p>

<p>For example, if <code>have_framework(&#39;Ruby&#39;)</code> returned true, then the <code>HAVE_FRAMEWORK_RUBY</code> preprocessor macro would be passed to the compiler.</p>

<p>If <code>fw</code> is a pair of the framework name and its header file name that header file is checked, instead of the normally used header file which is named same as the framework.</p>

                              <div class="method-source-code" id="have_framework-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1170</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_framework</span>(<span class="ruby-identifier">fw</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">fw</span>
    <span class="ruby-identifier">fw</span>, <span class="ruby-identifier">header</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">fw</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">header</span> = <span class="ruby-node">&quot;#{fw}.h&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">fw</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">src</span> = <span class="ruby-identifier">cpp_include</span>(<span class="ruby-node">&quot;#{fw}/#{header}&quot;</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-string">&quot;int main(void){return 0;}&quot;</span>
    <span class="ruby-identifier">opt</span> = <span class="ruby-node">&quot; -framework #{fw}&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_link</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>) <span class="ruby-keyword">or</span> (<span class="ruby-identifier">objc</span> = <span class="ruby-identifier">try_link</span>(<span class="ruby-identifier">src</span>, <span class="ruby-node">&quot;-ObjC#{opt}&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>))
      <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DHAVE_FRAMEWORK_%s&quot;</span>, <span class="ruby-identifier">fw</span>.<span class="ruby-identifier">tr_cpp</span>))
      <span class="ruby-comment"># TODO: non-worse way than this hack, to get rid of separating</span>
      <span class="ruby-comment"># option and its argument.</span>
      <span class="ruby-identifier">$LDFLAGS</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot; -ObjC&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">objc</span> <span class="ruby-keyword">and</span> <span class="ruby-regexp">/(\A|\s)-ObjC(\s|\z)/</span> <span class="ruby-operator">!~</span> <span class="ruby-identifier">$LDFLAGS</span>
      <span class="ruby-identifier">$LIBS</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">opt</span>
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_func" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_func</span><span
                                class="method-args">(func, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the function <code>func</code> can be found in the common header files, or within any <code>headers</code> that you provide.  If found, a macro is passed as a preprocessor constant to the compiler using the function name, in uppercase, prepended with <code>HAVE_</code>.</p>

<p>To check functions in an additional library, you need to check that library first using <code>have_library()</code>.  The <code>func</code> shall be either mere function name or function name with arguments.</p>

<p>For example, if <code>have_func(&#39;foo&#39;)</code> returned <code>true</code>, then the <code>HAVE_FOO</code> preprocessor macro would be passed to the compiler.</p>

                              <div class="method-source-code" id="have_func-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1107</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_func</span>(<span class="ruby-identifier">func</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">func</span>.<span class="ruby-identifier">funcall_style</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_func</span>(<span class="ruby-identifier">func</span>, <span class="ruby-identifier">$libs</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
      <span class="ruby-identifier">$defs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;-DHAVE_#{func.sans_arguments.tr_cpp}&quot;</span>
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_header" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_header</span><span
                                class="method-args">(header, preheaders = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the given <code>header</code> file can be found on your system. If found, a macro is passed as a preprocessor constant to the compiler using the header file name, in uppercase, prepended with <code>HAVE_</code>.</p>

<p>For example, if <code>have_header(&#39;foo.h&#39;)</code> returned true, then the <code>HAVE_FOO_H</code> preprocessor macro would be passed to the compiler.</p>

                              <div class="method-source-code" id="have_header-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1147</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_header</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">preheaders</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">dir_config</span>(<span class="ruby-identifier">header</span>[<span class="ruby-regexp">/.*?(?=\/)|.*?(?=\.)/</span>])
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">header</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_header</span>(<span class="ruby-identifier">cpp_include</span>(<span class="ruby-identifier">preheaders</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">cpp_include</span>(<span class="ruby-identifier">header</span>), <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
      <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DHAVE_%s&quot;</span>, <span class="ruby-identifier">header</span>.<span class="ruby-identifier">tr_cpp</span>))
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_library" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_library</span><span
                                class="method-args">(lib, func = nil, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the given entry point <code>func</code> can be found within <code>lib</code>.  If <code>func</code> is <code>nil</code>, the <code>main()</code> entry point is used by default.  If found, it adds the library to list of libraries to be used when linking your extension.</p>

<p>If <code>headers</code> are provided, it will include those header files as the header files it looks in when searching for <code>func</code>.</p>

<p>The real name of the library to be linked can be altered by <code>--with-FOOlib</code> configuration option.</p>

                              <div class="method-source-code" id="have_library-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1047</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_library</span>(<span class="ruby-identifier">lib</span>, <span class="ruby-identifier">func</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">dir_config</span>(<span class="ruby-identifier">lib</span>)
  <span class="ruby-identifier">lib</span> = <span class="ruby-identifier">with_config</span>(<span class="ruby-identifier">lib</span><span class="ruby-string">+&#39;lib&#39;</span>, <span class="ruby-identifier">lib</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">func</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">func</span>.<span class="ruby-identifier">funcall_style</span>, <span class="ruby-constant">LIBARG</span><span class="ruby-operator">%</span><span class="ruby-identifier">lib</span>, <span class="ruby-identifier">opt</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">COMMON_LIBS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">lib</span>)
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">libs</span> = <span class="ruby-identifier">append_library</span>(<span class="ruby-identifier">$libs</span>, <span class="ruby-identifier">lib</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_func</span>(<span class="ruby-identifier">func</span>, <span class="ruby-identifier">libs</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
        <span class="ruby-identifier">$libs</span> = <span class="ruby-identifier">libs</span>
        <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_macro" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_macro</span><span
                                class="method-args">(macro, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not <code>macro</code> is defined either in the common header files or within any <code>headers</code> you provide.</p>

<p>Any options you pass to <code>opt</code> are passed along to the compiler.</p>

                              <div class="method-source-code" id="have_macro-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1030</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_macro</span>(<span class="ruby-identifier">macro</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">macro</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">macro_defined?</span>(<span class="ruby-identifier">macro</span>, <span class="ruby-identifier">cpp_include</span>(<span class="ruby-identifier">headers</span>), <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_struct_member" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_struct_member</span><span
                                class="method-args">(type, member, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the struct of type <code>type</code> contains <code>member</code>.  If it does not, or the struct type can’t be found, then false is returned. You may optionally specify additional <code>headers</code> in which to look for the struct (in addition to the common header files).</p>

<p>If found, a macro is passed as a preprocessor constant to the compiler using the type name and the member name, in uppercase, prepended with <code>HAVE_</code>.</p>

<p>For example, if <code>have_struct_member(&#39;struct foo&#39;, &#39;bar&#39;)</code> returned true, then the <code>HAVE_STRUCT_FOO_BAR</code> preprocessor macro would be passed to the compiler.</p>

<p><code>HAVE_ST_BAR</code> is also defined for backward compatibility.</p>

                              <div class="method-source-code" id="have_struct_member-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1235</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_struct_member</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">member</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
    <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-node">&quot;#{type}.#{member}&quot;</span>, <span class="ruby-identifier">headers</span>) <span class="ruby-keyword">do</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_compile</span>(<span class="ruby-identifier">&lt;&lt;&quot;SRC&quot;</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
<span class="ruby-value">#{cpp_include(headers)}
/*top*/
int s = (char *)&amp;((#{type}*)0)-&gt;#{member} - (char *)0;
#{MAIN_DOES_NOTHING}
</span><span class="ruby-identifier">SRC</span>
        <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DHAVE_%s_%s&quot;</span>, <span class="ruby-identifier">type</span>.<span class="ruby-identifier">tr_cpp</span>, <span class="ruby-identifier">member</span>.<span class="ruby-identifier">tr_cpp</span>))
        <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DHAVE_ST_%s&quot;</span>, <span class="ruby-identifier">member</span>.<span class="ruby-identifier">tr_cpp</span>)) <span class="ruby-comment"># backward compatibility</span>
        <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_type" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_type</span><span
                                class="method-args">(type, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the static type <code>type</code> is defined.  You may optionally pass additional <code>headers</code> to check against in addition to the common header files.</p>

<p>You may also pass additional flags to <code>opt</code> which are then passed along to the compiler.</p>

<p>If found, a macro is passed as a preprocessor constant to the compiler using the type name, in uppercase, prepended with <code>HAVE_TYPE_</code>.</p>

<p>For example, if <code>have_type(&#39;foo&#39;)</code> returned true, then the <code>HAVE_TYPE_FOO</code> preprocessor macro would be passed to the compiler.</p>

                              <div class="method-source-code" id="have_type-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1283</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_type</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">try_type</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_var" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_var</span><span
                                class="method-args">(var, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the variable <code>var</code> can be found in the common header files, or within any <code>headers</code> that you provide.  If found, a macro is passed as a preprocessor constant to the compiler using the variable name, in uppercase, prepended with <code>HAVE_</code>.</p>

<p>To check variables in an additional library, you need to check that library first using <code>have_library()</code>.</p>

<p>For example, if <code>have_var(&#39;foo&#39;)</code> returned true, then the <code>HAVE_FOO</code> preprocessor macro would be passed to the compiler.</p>

                              <div class="method-source-code" id="have_var-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1129</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_var</span>(<span class="ruby-identifier">var</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">checking_for</span> <span class="ruby-identifier">checking_message</span>(<span class="ruby-identifier">var</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_var</span>(<span class="ruby-identifier">var</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
      <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DHAVE_%s&quot;</span>, <span class="ruby-identifier">var</span>.<span class="ruby-identifier">tr_cpp</span>))
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pkg_config" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pkg_config</span><span
                                class="method-args">(pkg, *options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns compile/link information about an installed library in a tuple of <code>[cflags, ldflags, libs]</code>, by using the command found first in the following commands:</p>
<ol><li>
<p>If <code>--with-{pkg}-config={command}</code> is given via command line option: <code>{command} {options}</code></p>
</li><li>
<p><code>{pkg}-config {options}</code></p>
</li><li>
<p><code>pkg-config {options} {pkg}</code></p>
</li></ol>

<p>Where <code>options</code> is the option name without dashes, for instance <code>&quot;cflags&quot;</code> for the <code>--cflags</code> flag.</p>

<p>The values obtained are appended to <code>$INCFLAGS</code>, <code>$CFLAGS</code>, <code>$LDFLAGS</code> and <code>$libs</code>.</p>

<p>If one or more <code>options</code> argument is given, the config command is invoked with the options and a stripped output string is returned without modifying any of the global values mentioned above.</p>

                              <div class="method-source-code" id="pkg_config-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1850</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pkg_config</span>(<span class="ruby-identifier">pkg</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">fmt</span> = <span class="ruby-string">&quot;not found&quot;</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fmt</span>.<span class="ruby-identifier">%</span>(<span class="ruby-identifier">x</span>)
    <span class="ruby-identifier">x</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">inspect</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">checking_for</span> <span class="ruby-node">&quot;pkg-config for #{pkg}&quot;</span>, <span class="ruby-identifier">fmt</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">_</span>, <span class="ruby-identifier">ldir</span> = <span class="ruby-identifier">dir_config</span>(<span class="ruby-identifier">pkg</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">ldir</span>
      <span class="ruby-identifier">pkg_config_path</span> = <span class="ruby-node">&quot;#{ldir}/pkgconfig&quot;</span>
      <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">pkg_config_path</span>)
        <span class="ruby-constant">Logging</span>.<span class="ruby-identifier">message</span>(<span class="ruby-string">&quot;PKG_CONFIG_PATH = %s\n&quot;</span>, <span class="ruby-identifier">pkg_config_path</span>)
        <span class="ruby-identifier">envs</span> = [<span class="ruby-string">&quot;PKG_CONFIG_PATH&quot;</span><span class="ruby-operator">=&gt;</span>[<span class="ruby-identifier">pkg_config_path</span>, <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;PKG_CONFIG_PATH&quot;</span>]].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>)]
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">pkgconfig</span> = <span class="ruby-identifier">with_config</span>(<span class="ruby-node">&quot;#{pkg}-config&quot;</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">find_executable0</span>(<span class="ruby-identifier">pkgconfig</span>)
    <span class="ruby-comment"># if and only if package specific config command is given</span>
    <span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">$PKGCONFIG</span> <span class="ruby-operator">||=</span>
           (<span class="ruby-identifier">pkgconfig</span> = <span class="ruby-identifier">with_config</span>(<span class="ruby-string">&quot;pkg-config&quot;</span>) {<span class="ruby-identifier">config_string</span>(<span class="ruby-string">&quot;PKG_CONFIG&quot;</span>) <span class="ruby-operator">||</span> <span class="ruby-string">&quot;pkg-config&quot;</span>}) <span class="ruby-operator">&amp;&amp;</span>
           <span class="ruby-identifier">find_executable0</span>(<span class="ruby-identifier">pkgconfig</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">pkgconfig</span>) <span class="ruby-keyword">and</span>
         <span class="ruby-identifier">xsystem</span>([<span class="ruby-operator">*</span><span class="ruby-identifier">envs</span>, <span class="ruby-identifier">$PKGCONFIG</span>, <span class="ruby-string">&quot;--exists&quot;</span>, <span class="ruby-identifier">pkg</span>])
      <span class="ruby-comment"># default to pkg-config command</span>
      <span class="ruby-identifier">pkgconfig</span> = <span class="ruby-identifier">$PKGCONFIG</span>
      <span class="ruby-identifier">args</span> = [<span class="ruby-identifier">pkg</span>]
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">find_executable0</span>(<span class="ruby-identifier">pkgconfig</span> = <span class="ruby-node">&quot;#{pkg}-config&quot;</span>)
    <span class="ruby-comment"># default to package specific config command, as a last resort.</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">pkgconfig</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">pkgconfig</span>
      <span class="ruby-identifier">get</span> = <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">opts</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;--#{o}&quot;</span> }
        <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">xpopen</span>([<span class="ruby-operator">*</span><span class="ruby-identifier">envs</span>, <span class="ruby-identifier">pkgconfig</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>], <span class="ruby-value">err:</span>[<span class="ruby-value">:child</span>, <span class="ruby-value">:out</span>], <span class="ruby-operator">&amp;</span><span class="ruby-value">:read</span>)
        <span class="ruby-constant">Logging</span>.<span class="ruby-identifier">open</span> {<span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each_line</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span><span class="ruby-node">&quot;=&gt; #{s.inspect}&quot;</span>}}
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">$?</span>.<span class="ruby-identifier">success?</span>
      }
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">orig_ldflags</span> = <span class="ruby-identifier">$LDFLAGS</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">get</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">get</span>[<span class="ruby-identifier">options</span>]
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">get</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">try_ldflags</span>(<span class="ruby-identifier">ldflags</span> = <span class="ruby-identifier">get</span>[<span class="ruby-string">&#39;libs&#39;</span>])
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">incflags</span> = <span class="ruby-identifier">get</span>[<span class="ruby-string">&#39;cflags-only-I&#39;</span>]
        <span class="ruby-identifier">$INCFLAGS</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">incflags</span>
        <span class="ruby-identifier">cflags</span> = <span class="ruby-identifier">get</span>[<span class="ruby-string">&#39;cflags-only-other&#39;</span>]
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">cflags</span> = <span class="ruby-identifier">get</span>[<span class="ruby-string">&#39;cflags&#39;</span>]
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">libs</span> = <span class="ruby-identifier">get</span>[<span class="ruby-string">&#39;libs-only-l&#39;</span>]
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">cflags</span>
        <span class="ruby-identifier">$CFLAGS</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">cflags</span>
        <span class="ruby-identifier">$CXXFLAGS</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">cflags</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">libs</span>
        <span class="ruby-identifier">ldflags</span> = (<span class="ruby-constant">Shellwords</span>.<span class="ruby-identifier">shellwords</span>(<span class="ruby-identifier">ldflags</span>) <span class="ruby-operator">-</span> <span class="ruby-constant">Shellwords</span>.<span class="ruby-identifier">shellwords</span>(<span class="ruby-identifier">libs</span>)).<span class="ruby-identifier">quote</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot; &quot;</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">libs</span>, <span class="ruby-identifier">ldflags</span> = <span class="ruby-constant">Shellwords</span>.<span class="ruby-identifier">shellwords</span>(<span class="ruby-identifier">ldflags</span>).<span class="ruby-identifier">partition</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/-l([^ ]+)/</span> }.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span><span class="ruby-identifier">l</span>.<span class="ruby-identifier">quote</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot; &quot;</span>)}
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">$libs</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">libs</span>

      <span class="ruby-identifier">$LDFLAGS</span> = [<span class="ruby-identifier">orig_ldflags</span>, <span class="ruby-identifier">ldflags</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)
      <span class="ruby-constant">Logging</span><span class="ruby-operator">::</span><span class="ruby-identifier">message</span> <span class="ruby-string">&quot;package configuration for %s\n&quot;</span>, <span class="ruby-identifier">pkg</span>
      <span class="ruby-constant">Logging</span><span class="ruby-operator">::</span><span class="ruby-identifier">message</span> <span class="ruby-string">&quot;incflags: %s\ncflags: %s\nldflags: %s\nlibs: %s\n\n&quot;</span>,
                       <span class="ruby-identifier">incflags</span>, <span class="ruby-identifier">cflags</span>, <span class="ruby-identifier">ldflags</span>, <span class="ruby-identifier">libs</span>
      [[<span class="ruby-identifier">incflags</span>, <span class="ruby-identifier">cflags</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>), <span class="ruby-identifier">ldflags</span>, <span class="ruby-identifier">libs</span>]
    <span class="ruby-keyword">else</span>
      <span class="ruby-constant">Logging</span><span class="ruby-operator">::</span><span class="ruby-identifier">message</span> <span class="ruby-string">&quot;package configuration for %s is not found\n&quot;</span>, <span class="ruby-identifier">pkg</span>
      <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-try_const" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">try_const</span><span
                                class="method-args">(const, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the constant <code>const</code> is defined.</p>

<p>See also <code>have_const</code></p>

                              <div class="method-source-code" id="try_const-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1313</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">try_const</span>(<span class="ruby-identifier">const</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
    <span class="ruby-identifier">const</span>, <span class="ruby-identifier">type</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">const</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_compile</span>(<span class="ruby-identifier">&lt;&lt;&quot;SRC&quot;</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
<span class="ruby-value">#{cpp_include(headers)}
/*top*/
typedef #{type || &#39;int&#39;} conftest_type;
conftest_type conftestval = #{type ? &#39;&#39; : &#39;(int)&#39;}#{const};
</span><span class="ruby-identifier">SRC</span>
      <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DHAVE_CONST_%s&quot;</span>, <span class="ruby-identifier">const</span>.<span class="ruby-identifier">tr_cpp</span>))
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-try_type" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">try_type</span><span
                                class="method-args">(type, headers = nil, opt = &quot;&quot;, &amp;b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not the static type <code>type</code> is defined.</p>

<p>See also <code>have_type</code></p>

                              <div class="method-source-code" id="try_type-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1256</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">try_type</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">headers</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">try_compile</span>(<span class="ruby-identifier">&lt;&lt;&quot;SRC&quot;</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
<span class="ruby-value">#{cpp_include(headers)}
/*top*/
typedef #{type} conftest_type;
int conftestval[sizeof(conftest_type)?1:-1];
</span><span class="ruby-identifier">SRC</span>
      <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;-DHAVE_TYPE_%s&quot;</span>, <span class="ruby-identifier">type</span>.<span class="ruby-identifier">tr_cpp</span>))
      <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-with_config" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">with_config</span><span
                                class="method-args">(config, default=nil) { |config, default| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Tests for the presence of a <code>--with-</code><em>config</em> or <code>--without-</code><em>config</em> option.  Returns <code>true</code> if the with option is given, <code>false</code> if the without option is given, and the default value otherwise.</p>

<p>This can be useful for adding custom definitions, such as debug information.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-keyword">if</span> <span class="ruby-identifier">with_config</span>(<span class="ruby-string">&quot;debug&quot;</span>)
   <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-string">&quot;-DOSSL_DEBUG&quot;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">$defs</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;-DOSSL_DEBUG&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="with_config-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 1670</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">with_config</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">default</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^--with[-_]/</span>, <span class="ruby-string">&#39;&#39;</span>)
  <span class="ruby-identifier">val</span> = <span class="ruby-identifier">arg_config</span>(<span class="ruby-string">&quot;--with-&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">config</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg_config</span>(<span class="ruby-string">&quot;--without-&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">config</span>)
      <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">block_given?</span>
      <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">default</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">break</span> <span class="ruby-identifier">default</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">val</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;yes&quot;</span>
    <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;no&quot;</span>
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">val</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-cc_command" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cc_command</span><span
                                class="method-args">(opt=&quot;&quot;)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="cc_command-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2870</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cc_command</span>(<span class="ruby-identifier">opt</span>=<span class="ruby-string">&quot;&quot;</span>)
  <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">cc_config</span>(<span class="ruby-identifier">opt</span>)
  <span class="ruby-constant">RbConfig</span><span class="ruby-operator">::</span><span class="ruby-identifier">expand</span>(<span class="ruby-node">&quot;$(CXX) #$INCFLAGS #$CPPFLAGS #$CXXFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_CXX}&quot;</span>,
                   <span class="ruby-identifier">conf</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-conftest_source" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">conftest_source</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="conftest_source-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2866</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">conftest_source</span>
  <span class="ruby-constant">CONFTEST_CXX</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-have_devel-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_devel?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="have_devel-3F-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2858</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">have_devel?</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span> <span class="ruby-ivar">@have_devel</span>
    <span class="ruby-ivar">@have_devel</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-ivar">@have_devel</span> = <span class="ruby-identifier">try_link</span>(<span class="ruby-constant">MAIN_DOES_NOTHING</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@have_devel</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-link_command" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">link_command</span><span
                                class="method-args">(ldflags, *opts)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="link_command-source">
            <pre><span class="ruby-comment"># File mkmf.rb, line 2876</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">link_command</span>(<span class="ruby-identifier">ldflags</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>)
  <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">link_config</span>(<span class="ruby-identifier">ldflags</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>)
  <span class="ruby-constant">RbConfig</span><span class="ruby-operator">::</span><span class="ruby-identifier">expand</span>(<span class="ruby-constant">TRY_LINK_CXX</span>.<span class="ruby-identifier">dup</span>, <span class="ruby-identifier">conf</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

